﻿@model Inovout.Membership.Security.DynamicPasswordCredential
@using System.Web.Optimization
@{
    
    Layout = "~/Views/Layout/_LayoutForPC.cshtml";
   
}
@section customStyle{
    <style>
        .header {
            height: 30px;
            background-color: #07b921;
            color: white;
            line-height: 30px;
            margin-bottom: 10px;
        }

        #a_code {
            line-height: 34px;
            height: 34px;
        }


    </style>
}
@section customScript{
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script type="text/javascript">
        var pageLogic = {};
        $(document).ready(function () {
            $("#phone").blur(function () {
                $("#a_code").prop("href", "/Account/GetDynamicPassword?phone=" + $(this).val() + "&ReturnUrl=" + '@ViewBag.ReturnUrl');
            })

            $("#a_code").click(function () {
                if (!$("#phone").val()) {
                    $("#dynamicForm").submit();
                   // alert("请输入手机号码");

                } else {
                    pageLogic.GetPassWord();
                }
                return false;
            })
        })

        pageLogic.GetPassWord = function () {
            $.ajax({
                url: '@Url.Action("GetDynamicPassword", new { ran=new Random().Next(1000)})', 
                dataType: "json",
                type: "GET",
                data: { phone: $("#phone").val() },
                success: function (data) {
                    $("#code").val(data.Code);
                    $("#code").focus();
                   // $("#formsubmit").focus();
                }
            });
        }

    </script>
}
<div class="container-fluid">
    <div class="row header">
        <div class="col-xs-4">
            <span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span>
        </div>
        <div class="col-xs-4">
            <strong>加入成功</strong>
        </div>
        <div class="col-xs-4" style="text-align: right;">
            <strong>客服</strong>
        </div>
    </div>
    @using (Html.BeginForm("DynamicPassword", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal",@id="dynamicForm" }))
    {      
     //  @Html.ValidationSummary(true)
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-3 control-label">手机号码：</label>
            <div class="col-sm-6">
                @Html.TextBoxFor(x => x.Phone, new { @class = "form-control", @placeholder = "手机号码", @id = "phone", @type="tel"})
            </div>
            <div class="col-sm-12 col-sm-offset-3">
                @Html.ValidationMessageFor(x => x.Phone)
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-3 control-label">验证码：</label>
            <div class="col-sm-3">
                @Html.TextBoxFor(x => x.Code, new { @class = "form-control", @placeholder = "验证码", @id = "code" })
            </div>
            <div class="col-sm-3">
                @Html.ActionLink("获取验证码", "GetDynamicPassword", null, new { @id = "a_code" })
            </div>
            <div class="col-sm-12  col-sm-offset-3">
                 @Html.ValidationMessageFor(x => x.Code)
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-3"></div>
            <div class="col-sm-9">
                <input type="submit" id="formsubmit" class="btn btn-default" value="立即验证" />
            </div>
        </div>
       
    }


</div>

